package com.qqtech.qquan.homemaking.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.homemaking.dao.HomemakingPubitemDao;
import com.qqtech.qquan.homemaking.model.HomemakingPubitem;
import com.qqtech.qquan.homemaking.model.HomemakingPubitemQuery;
import com.qqtech.qquan.homemaking.model.HomemakingPubitemVo;

@Service
public class HomemakingPubitemServiceImpl extends BaseServiceImpl<HomemakingPubitem>
		implements HomemakingPubitemService {
	public static final Logger log = LoggerFactory.getLogger(HomemakingPubitemServiceImpl.class);
	
	@Resource
	private HomemakingPubitemDao homemakingPubitemDao;

	@Override
	protected BaseDao<HomemakingPubitem> getBaseDao() {
		return homemakingPubitemDao;
	}

	@Override
	public List<HomemakingPubitemVo> findByTypeId(Integer typeId, Integer status) {
		if (typeId == null) {
			return null;
		}
		HomemakingPubitemQuery q = new HomemakingPubitemQuery();
		q.setTypeId(typeId);
		q.setStatus(status);
		Pageable pageKit = new PageKit(q.getPage(), new PageOrder(Direction.ASC, "id")); 
		return homemakingPubitemDao.queryList(q, pageKit);
	}

	@Override
	public Page<HomemakingPubitemVo> queryPageListAdmin(
			HomemakingPubitem query, Pageable pageable) {
		return homemakingPubitemDao.queryPageListAdmin(query, pageable);
	}
	
}